using System.Threading;
using Mistral.Windows;

namespace Mistral.SecureDrive
{
	public class ThreadedProgress
	{
		private ProgressWindow _progressWindow;
		private EventWaitHandle WindowCreated = new ManualResetEvent( false );
		private Thread _thread;
			
		public ProgressWindow Show()
		{
			_thread = new Thread( ProgressWindowThread );
			_thread.Name = "ProgressWindowThread";
			_thread.IsBackground = true;
			_thread.Start();
			WindowCreated.WaitOne( );
			return _progressWindow;
		}

		private void ProgressWindowThread()
		{
			_progressWindow = new ProgressWindow();
			WindowCreated.Set( );				
			_progressWindow.ShowDialog();
		}	
	}
}